<?php

namespace app\admin\model\choi;

use think\Model;


class Star extends Model
{

    

    

    // 表名
    protected $table = 'star';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'quarterdata_text',
        'onlineswitch_text',
        'tagswitch_text'
    ];
    

    protected static function init()
    {
//        self::afterInsert(function ($row) {
//            $pk = $row->getPk();
//            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
//        });
    }

    
    public function getQuarterdataList()
    {
        return ['Q1' => __('Q1'), 'Q2' => __('Q2'), 'Q3' => __('Q3'), 'Q4' => __('Q4')];
    }

    public function getOnlineswitchList()
    {
        return ['0' => __('Onlineswitch 0'), '1' => __('Onlineswitch 1')];
    }

    public function getTagswitchList()
    {
        return ['0' => __('Tagswitch 0'), '1' => __('Tagswitch 1')];
    }


    public function getQuarterdataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['quarterdata']) ? $data['quarterdata'] : '');
        $list = $this->getQuarterdataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getOnlineswitchTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['onlineswitch']) ? $data['onlineswitch'] : '');
        $list = $this->getOnlineswitchList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getTagswitchTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['tagswitch']) ? $data['tagswitch'] : '');
        $list = $this->getTagswitchList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
